<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
</head>
<body>

<h2>JavaScript HTML DOM!</h2>

<p>Hello World!</p>

<p>Hello Runoob!</p>

<p>点击按钮修改所有 p 元素的背景颜色。</p>

<button onclick="myFunction()">点我</button>

<script>
    function myFunction() {
        var myNodelist = document.getElementsByTagName('p');
        var i;
        for (i = 0; i < myNodelist.length; i++) {
            myNodelist[i].style.backgroundColor = "hotpink";
        }
    }
</script>

</body>
</html>